import request  from '@/utils/request';
import { defineStore } from 'pinia';
import { CheckoutInfo } from '@/types/checkout'
import { ApiRes } from '@/types/data';

const useCheckoutStore = defineStore('checkout', {
  state() {
     return {
        // 订单数据
        checkoutInfo: {} as CheckoutInfo
     } 
  }, 
  actions: {
    // 获取订单信息
    async getCheckoutInfo () {
      const res = await request.get<ApiRes<CheckoutInfo>>('/member/order/pre')
      console.log('订单信息', res.data);
      this.checkoutInfo = res.data.result
    }
  }
})

export default useCheckoutStore
